home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
ML_3DROT.ZIP
/
SOURCES
/
FIG2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-12-26
|
3KB
|
133 lines
{
Example of using the 3D "engine", by Maple Leaf, 1996
This code is freeware. If you find it useful, feel free to do whatever
you want with it, with only one condiion: give some small greetings to
Maple Leaf in your productions that use parts of it.
Maple Leaf, '96
btw, I'm too lazy to write down kilos of comments... :-)
}
uses xmode,crt,engine3d;
var a,b:word;
pal:array[byte] of record r,g,b:byte end;
capag,cvpag : word;
dd:integer;
coord:array[0..730] of record x,y,z:integer end;
RealMapping : Boolean;
ch:char;
MaxPnt:word;
RotStep,TiltStep:longint;
Procedure GenFig;
var cnt,i,j,k:word;
begin
cnt:=0;
for i:=0 to 6 do
for j:=0 to 6 do
for k:=0 to 6 do begin
with coord[cnt] do begin
x:=i shl 3-28;
y:=j shl 3-28;
z:=k shl 3-28;
end;
inc(cnt);
end;
MaxPnt:=cnt
end;
Procedure PuneFig;
var i:integer; cnt:word;
begin
cnt:=0;
{xvwait;}
xclrvpage(capag);
for i:=0 to MaxPnt-1 do begin
_3dx:=coord[i].x+100;
_3dy:=coord[i].y;
_3dz:=coord[i].z+10;
asm
cmp RealMapping,1
je @1
call IntMapCoordinates
jmp @2
@1:call MapCoordinates
@2:
end;
xvplot(_2dx,_2dy,(i+2) shr 1,capag);
end;
end;
Procedure IntroText;
begin
Writeln('3D Figure, by Maple Leaf, 1996.');
Writeln(#13#10,' Hot keys are:'#13#10);
Writeln(' <M> - Change mapping method (float/integer)');
Writeln(' <Left> - Decrement horizontal speed of rotation');
Writeln(' <Right> - Increment horizontal speed of rotation');
Writeln(' <Up> - Increment vertical speed of rotation');
Writeln(' <Down> - Decrement vertical speed of rotation');
Writeln(#13#10'Press a key to start ...');
Readkey;
end;
begin
ClrScr;
GenFig;
IntroText;
xinitvideo(0);
xclrvram;
for a:=1 to 255 do with pal[a] do begin
r:=Trunc(63*a/255);
g:=Trunc(40);
b:=Trunc(63-63*a/255);
end;
xsetpalette(@pal);
ZoomFactor:=500;
Perspective:=True;
SetObserverPosition(0,0,500);
SetAngles(0,0);
capag:=0;
cvpag:=3;
dd:=10;
RealMapping:=false;
RotStep:=2;
TiltStep:=3;
repeat
repeat
xvwait;
xsetvpage(cvpag);
RotAngle:=RotAngle+RotStep;
TiltAngle:=TiltAngle+TiltStep;
if RotAngle>359 then RotAngle:=360-RotAngle;
if RotAngle<0 then RotAngle:=360+RotAngle;
if TiltAngle>359 then TiltAngle:=360-TiltAngle;
if TiltAngle<0 then TiltAngle:=360+TiltAngle;
{SetAngles(RotAngle,TiltAngle);}
PuneFig;
inc(capag); if capag>3 then capag:=0;
inc(cvpag); if cvpag>3 then cvpag:=0;
until keypressed;
ch:=readkey;
case UpCase(ch) of
'M': { Mapping mode } RealMapping:=not RealMapping;
#0: begin
ch:=readkey;
case ch of
#72: {Up} inc(RotStep);
#80: {Down} dec(RotStep);
#75: {Left} dec(TiltStep);
#77: {Right} inc(TiltStep);
end;
end;
end;
until ch=#27;
textmode(25);
end.